import requests


def getWeather():
    city = input("请输入要查询天气的城市：")
    url = 'http://widget.cifuwu.com/weather/' +str(city)
    result = requests.get(url)
    data = result.json()
    print("当前位置: " + data["data"]["alert"][0]["province"]+"省"+data["data"]["alert"][0]["city"]+"市"+data["data"]["alert"][0]["county"]+"市")
    print("当前时间: " + data["data"]["pubdate"]+" "+data["data"]["pubtime"])
    print("当前温度: " + str(data["data"]["realtime"]["weather"]["temperature"]+'℃'))
    print("天气： " + str(data["data"]["realtime"]["weather"]["info"]) + ",有"+str(data["data"]["realtime"]["wind"]["power"]) + str(data["data"]["realtime"]["wind"]["direct"]))
    print("温馨提示: " )
    print("舒适度: " + str(data["data"]["life"]["info"]["shushidu"]))
    print("穿衣: " + str(data["data"]["life"]["info"]["chuanyi"]))
    print("感冒: " + str(data["data"]["life"]["info"]["ganmao"]))
    print("紫外线: " + str(data["data"]["life"]["info"]["ziwaixian"]))
    print("运动: " + str(data["data"]["life"]["info"]["yundong"]))
    print("带伞: " + str(data["data"]["life"]["info"]["daisan"]))
    print("天气预警: " + data["data"]["alert"][0]["alarmTp1"] + data["data"]["alert"][0]["alarmTp2"] +"\n"+"发布时间:"+data["data"]["alert"][0]["pubTime"] +"\n"+"具体内容:"+ data["data"]["alert"][0]["content"])

getWeather()